namespace FIREFLYX {
    /** 简单线条绘制 着色器 */
    export const BUILTIN_SHADER_SIMPLE_LINE = `simpleLine`;
    DefaultAsset.shaderGenMap[BUILTIN_SHADER_SIMPLE_LINE] = () => {
        const vsCode = `#version 300 es
            precision highp float;
            layout (location = 0) in vec4 a_Position; //顶点 位置 是有默认值的 (0,0,0,1)
            uniform ubo_cam_block{
                mat4 u_viewMtx;             //视窗矩阵
                mat4 u_projectMtx;          //投影矩阵
                vec4 u_eyePos;              //眼睛位置
            } uboCam;
            void main() {
                mat4 vpMat = uboCam.u_projectMtx * uboCam.u_viewMtx;    //顶点数据已经是世界坐标,不需要M矩阵.
                gl_Position = vpMat * vec4(a_Position.xyz , 1.0);
            }
        `;

        const fsCode = `#version 300 es
            precision highp float;
            precision highp int;
            uniform vec4 u_mainColor;       //主颜色 颜色
            out vec4 color;
            void main(){
                color = u_mainColor;
            }
        `;
        //glsl
        const vs = new GLSL();
        vs.setCode(vsCode);
        const fs = new GLSL();
        fs.setCode(fsCode);

        //shader
        let result: Shader = new Shader();
        result.tag = BUILTIN_SHADER_SIMPLE_LINE;
        result.lightMode = RenderPipeline.LM_FORWARD;
        result.vertexGLSL = vs;
        result.fragmentGLSL = fs;
        //unifrom 默认值
        result.definePropertyMap = {};

        result.definePropertyMap["u_mainColor"] = {
            type: "color",
            value: [1, 0, 1, 1]
        };

        //apply
        result.apply();

        return result;
    };
}